#include<iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    
    int n,maxNum,maxlen=0,cur=1;
    string temp,maxstring="";
    scanf("%d",&n);
    while (n--)
    {
        cin>>temp;
        if (maxlen < temp.size())
        {
            maxlen = temp.size();
            maxstring = temp;
            maxNum = cur;
        }
        else if(maxlen == temp.size()){
            for (int i = 0; i < maxlen; i++)
            {
                if(temp[i] > maxstring[i]){
                    maxstring = temp;
                    maxNum = cur;
                    break;
                }else if(temp[i] < maxstring[i]){
                    break;
                }
            }
            
        }
        cur++;
    }
    cout<<maxNum<<endl<<maxstring;
    return 0;
}
